package top.ckxgzxa.newscms.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import top.ckxgzxa.newscms.entity.dto.UserDto;

import javax.validation.Valid;
import java.util.HashMap;
import java.util.Map;

/**
 * @author 赵希奥
 * @date 2022/5/25 11:02
 * @gitHub https://github.com/CKXGZXA
 * @gitee https://gitee.com/ckxgzxa
 * @description: 测试用Controller
 */
@RestController
@RequestMapping("/test")
public class TestController {

    @GetMapping
    @PreAuthorize("hasAuthority('test')")
    public Map<String, String> test() {
        Map<String, String> map = new HashMap<>();
        map.put("name", "赵希奥");
        map.put("age", "22");
        return map;
    }

    @PostMapping("/register")
    public UserDto register(@Valid @RequestBody UserDto userDto) {
        return userDto;
    }

}
